package com.lz.fruitday.ui;

import android.support.v4.app.Fragment;

import android.os.Bundle;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.lz.fruitday.R;
import com.lz.fruitday.fragment.FirstFragment;
import com.lz.fruitday.fragment.FoodFragment;
import com.lz.fruitday.fragment.GardenFragment;
import com.lz.fruitday.fragment.KindFragment;
import com.lz.fruitday.fragment.ShopCarFragment;
import com.lz.fruitday.utils.FragmentTabUtils;
import com.lz.fruitday.widget.TitleBar;

import java.util.ArrayList;

public class MainActivity extends BaseActivity implements FragmentTabUtils.OnRgsExtraCheckedChangedListener {

    private RadioGroup rg;
    private ArrayList<Fragment> fragments;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        rg = (RadioGroup) findViewById(R.id.main_rg);
        fragments = new ArrayList<Fragment>();
        fragments.add(new FirstFragment());
        fragments.add(new KindFragment());
        fragments.add(new GardenFragment());
        fragments.add(new ShopCarFragment());
        fragments.add(new FoodFragment());
        new FragmentTabUtils(getSupportFragmentManager(), fragments, R.id.main_fragment_container, rg, this);
        titleBar.showHomeView();
    }

    @Override
    public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {
        switch (index) {
            case 0:
                titleBar.showHomeView();
                break;
            case 1:
                titleBar.showKindView();
                break;
            case 2:
                titleBar.showGarden();
                break;
            case 3:
                titleBar.showShopCar();
                break;
            case 4:
                titleBar.showFood();
                break;
        }
    }

}
